function getScenery(){
    $.ajax({
        url:'/Main/getScenery',
        type:'post',
        success(res){
            Main.content=res;
        }
    })
}
function xxx() {
    $('#info').css('display','none');
    $('#record').css('display','none');
    $('#suggestion').css('display','none');
    $('#consult').css('display','none');
    $('#manager').css('display','none');
    $('#self').css('display','none');
}
function getPrice(){
    $.ajax({
        url:'/Main/getPrice',
        type:'post',
        success(res){
            Main.content=res;
            xxx();
        }
    })
}
function exit() {
    $.ajax({
        url:'/Exit',
        type:'post',
        success(res){
            window.location.href = '/Login'
        }
    })
}
function exitAdmin() {
    $.ajax({
        url:'/ExitAdmin',
        type:'post',
        success(res){
            window.location.href = '/LoginAdmin'
        }
    })
}
function setPrice() {
    $.ajax({
        url:'/Main/setPrice',
        type:'post',
        success(res){
            Main.content=res;
        }
    })
}

function setScenery() {
    $.ajax({
        url:'/Main/setScenery',
        type:'post',
        success(res){
            contents=res;
        }
    })
}

//定义对应的实体
var userInfo = {
    user_id: '',
    user_account: '',
    user_name: '',
    user_pwd: '',
    email: '',
    phoneNumber: ''
};
//对象
var questionTable = {
    question_id:'',
    title:'',
    click_time:0,
    answer:'',
    classify_title:'',
    classify_level:0,
};
//对象
var suggestion = {
    suggestion_id:'',
    title:'',
    content:'',
    user_account:'',
    state:0
};
//对象
var consultLog={
    log_id:'',
    start_time:'',
    deal_time:'',
    user_account:'',
    employee_account:'',
    detail:'',
    satisfy:0.0,
    is_solved:0
};
//对象
var employee={
    employee_id:'',
    employee_name:'',
    employee_account:'',
    employee_pwd:'',
    satisfy:0.0,
    authority:0,
    email:'',
    phoneNumber:''
};

const consults =  [
    {
        title: 'id',
        key: 'log_id'
    },
    {
        title: '开始时间',
        key: 'start_time'
    },
    {
        title: '结束时间',
        key: 'deal_time'
    },
    {
        title:'员工编号',
        key:'employee_account'
    },
    {
        title:'满意度',
        key:'satisfy'
    },
    {
        title: '是否解决',
        key: 'is_solved'
    },{
        title:'详情',
        key:'detail'
    }
];
//数组
var questions=[];
var classify=[];
var classify2=[];
function getMostClick() {
    $.ajax({
        url:'/SelfService/searchMost',
        type:'post',
        success(res){
            questions=res;
            console.log(questions);
            Main.questionList=questions;
        }
    })
}
function getClassify() {
    $.ajax({
        url:'/SelfService/searchClassify',
        type:'post',
        success(res){
            classify=res;
            console.log(classify);
            Main.classify=classify;

        }
    })
}
function getQuestionTitle(classify) {
    $.ajax({
        url:'/SelfService/searchTitle',
        type:'post',
        data:{
            'classifyTitle':classify
        },
        success(res){
            classify2=res;
            console.log(res);
            Main.classify2=classify2;

        }
    })
}
var answers=[];
function getAnswer(title) {
    $.ajax({
        url:'/SelfService/searchAnswer',
        type:'post',
        data:{
            'title':title
        },
        success(res){
            answers=res;
            console.log(answers);
            Main.answers=answers;
        }
    })
}
function setCondition(choose) {
    Main.choose=choose;
}

function getAnswerByClassify(title) {
    $.ajax({
        url:'/SelfService/searchByNameAndClassify',
        type:'post',
        data:{
            'classify':Main.choose,
            'title':title
        },
        success(res){
            answers=res;
            console.log(answers);
            Main.answers=answers;
        }
    });

    $('#answers').css('display','block');
}

function getAnswerByKey(key) {
    $.ajax({
        url:'/SelfService/searchByKey',
        type:'post',
        data:{
            'key':key
        },
        success(res){
            answers=res;
            console.log(answers);
            Main.answers=answers;
        }
    });

    $('#answers').css('display','block');
}

function sendSuggestion(suggestion) {
    // $.ajax({
    //     url:'/Suggestion/send',
    //     type:'post',
    //     data:{
    //         'suggestion':suggestion
    //     },
    //     success(res){
    //         alert(res);
    //     }
    // });
    alert("ok")
}
var formCustom ={
    passwd: '',
    passwdCheck: '',
};
function handleSubmit (name) {
    console.log(name);
}
function handleReset (name) {
    Main.userInfo=userInfo;
}

function getRecords() {
    $.ajax({
        url:'/Record/search',
        type:'post',
        success(res){
            Main.consultsData=res;
            console.log(res);
        }
    });

}

